setwd("C:/Users/hbenc/OneDrive - Central European University/Backup_data_2024/Research Projects/Scandal/MeToo/rr_bjpols/replication files/obs")
getwd()
library(essurvey)
library(dplyr)
library(foreign)
library(haven)
library(effects)
library(psych)
library(Matching)
library(MatchIt)
library(RItools)
library(rlang)
library(Hmisc)
library(optmatch)
library(cem)
library(tableone)
library(kable)
library(kableExtra)
library(texreg)
library(effects)
library(stargazer)
library(sjPlot)
library(R.utils)
library(readxl)
library(cobalt)
library(ggplot2)
library(ggpubr)
library(grid)
library(ggridges)
library(labelled)
library(patchwork)
library(cowplot)
library(lme4)
library(lmerTest)
library(sjstats)
library(tidyr)
library(corrr)
library(lme4)
library(lmerTest)
library(sjstats)
library(glmmTMB)
library(lme4)
library(sjPlot)
library(XML)
library(RCurl)
library(rlist)
library(janitor)
library(dplyr)
library(knitr)
library(interflex)
library(stringi)
library(stringr)
library(lubridate)
library(nycflights13)
library(tidyverse)
trump <- read.csv("pres_approve.csv", header=TRUE, sep=",")
trump$date <- mdy(trump$End.Date)
trump$net <- trump$Approving-trump$Disapproving
trump$pres <- "Donald J. Trump"
clinton <- read.csv("pres_approve2.csv", header=TRUE, sep=",")
clinton$date <- mdy(clinton$End.Date)
clinton$net <- clinton$Approving-clinton$Disapproving
clinton$pres <- "Bill Clinton"
trump_plot <- ggplot(trump, aes(x=date, y=net)) +
geom_line(size=1) + theme_bw() +
theme(axis.text.x=element_text(angle=0, hjust=1, size=10),
axis.text.y=element_blank(),
axis.title.y=element_blank()) +
ylab("Net Approval") +
xlab("") + scale_x_date(date_labels = "%Y %b %d",
limit=c(as.Date("2017-12-25"),as.Date("2018-06-01"))) + theme(axis.text.x=element_text(angle=30, hjust=1)) +
geom_vline(xintercept= as.numeric(as.Date("2018-01-13")), linetype=3, size=1, color="red") + ## Stormy D. alleg.
geom_vline(xintercept= as.numeric(as.Date("2018-01-25")), linetype=3, size=1, color="red") + ## Trump denies
geom_vline(xintercept= as.numeric(as.Date("2018-02-12")), linetype=3, size=1, color="red")  + ## Cohen admits
geom_vline(xintercept= as.numeric(as.Date("2018-03-06")), linetype=3, size=1, color="red")  +## Stormy lawsuit, Trump denies
geom_vline(xintercept= as.numeric(as.Date("2018-03-25")), linetype=3, size=1, color="red") + ## 60 mins interview, Trump still denies
geom_vline(xintercept= as.numeric(as.Date("2018-04-01")), linetype=3, size=1, color="red")  + ## Trump denies
geom_vline(xintercept= as.numeric(as.Date("2018-04-09")), linetype=3, size=1, color="red")  +## Cohen faces crim. investigation
geom_vline(xintercept= as.numeric(as.Date("2018-04-20")), linetype=3, size=1, color="red") + ## Trump denies
geom_vline(xintercept= as.numeric(as.Date("2018-05-05")), linetype=3, size=1, color="red") + ## Trump admits
geom_text(aes(x = as.Date("2018-01-09"), y = 30, label = "Stormy D. alleg."), angle=90, size=4) +
geom_text(aes(x = as.Date("2018-01-21"), y = 30, label = "Trump denies"), angle=90, size=4) +
geom_text(aes(x = as.Date("2018-02-08"), y = 30, label = "Cohen admits"), angle=90, size=4) +
geom_text(aes(x = as.Date("2018-02-27"), y = 30, label = "Stormy D. lawsuit, \n Trump denies"), angle=90, size=4) +
geom_text(aes(x = as.Date("2018-03-18"), y = 30, label = "Interview with Stormy D., \n Trump denies"), angle=90, size=4) +
geom_text(aes(x = as.Date("2018-03-29"), y = 30, label = "Trump denies"), angle=90, size=4) +
geom_text(aes(x = as.Date("2018-04-06"), y = 30, label = "Cohen arrested"), angle=90, size=4) +
geom_text(aes(x = as.Date("2018-04-17"), y = 30, label = "Trump denies"), angle=90, size=4) +
geom_text(aes(x = as.Date("2018-05-02"), y = 30, label = "Trump admits"), angle=90, size=4) +
ggtitle("Trump: Stormy Daniels Scandal Timeline") + ylim(-30,50)
trump_plot
Sys.setlocale("LC_TIME", "English")
clinton_plot <- ggplot(clinton, aes(x=date, y=net)) +
geom_line(size=1) + theme_bw() +
xlab("") + scale_x_date(date_labels = "%Y %b %d",
limit=c(as.Date("1998-01-01"),as.Date("1999-02-01"))) +
theme(axis.text.x=element_text(angle=30, hjust=1, size=10),
axis.text.y=element_text(angle=0, hjust=1, size=12),
axis.title.y=element_text(angle=90, hjust=0.5, size=13)) +
ylab("Net Approval") + geom_vline(xintercept = as.numeric(as.Date("1998-01-19")),
linetype=3, size=1, color="red") +
geom_vline(xintercept = as.numeric(as.Date("1998-02-01")),
linetype=3, size=1, color="red") +
geom_vline(xintercept = as.numeric(as.Date("1998-08-14")),
linetype=3, size=1, color="red") +
geom_vline(xintercept = as.numeric(as.Date("1998-12-20")),
linetype=3, size=1, color="red") +
geom_text(aes(x = as.Date("1998-01-10"), y = -15, label = "Lewinsky Alleg."), angle=90, size=4) +
geom_text(aes(x = as.Date("1998-02-08"), y = -15, label = "Clinton Denies"), angle=90, size=4) +
geom_text(aes(x = as.Date("1998-08-05"), y = -15, label = "Clinton Admits"), angle=90, size=4) +
geom_text(aes(x = as.Date("1998-05-01"), y = 5, label = "Legal Investigations"), angle=0, size=4) +
geom_text(aes(x = as.Date("1998-12-11"), y = -10, label = "House Impeachment"), angle=90, size=4) +
geom_segment(aes(x=as.Date("1998-02-10"), y=0, xend=as.Date("1998-08-10"), yend=0), linetype=3, size=1, color="red") +
ggtitle("Clinton: Lewinsky Scandal Timeline") + ylim (-30,50)
clinton_plot
plot_grid(clinton_plot, trump_plot)
ggsave("fig4_final.png", width = 12, height = 7, dpi = 600)
ggsave("fig4_final.png", width = 14, height = 5, dpi = 600)
ggsave("fig4_final.png", width = 14, height = 7, dpi = 600)
trump <- read.csv("pres_approve.csv", header=TRUE, sep=",")
trump$date <- mdy(trump$End.Date)
library(sPlusTimeDate)
library(splusTimeDate)
trump$date <- mdy(trump$End.Date)
library(ggplot2)
library(ggpubr)
library(cowplot)
library(lubridate)
library(nycflights13)
library(tidyverse)
trump <- read.csv("pres_approve.csv", header=TRUE, sep=",")
trump$date <- mdy(trump$End.Date)
trump$net <- trump$Approving-trump$Disapproving
trump$pres <- "Donald J. Trump"
clinton <- read.csv("pres_approve2.csv", header=TRUE, sep=",")
clinton$date <- mdy(clinton$End.Date)
clinton$net <- clinton$Approving-clinton$Disapproving
clinton$pres <- "Bill Clinton"
trump_plot <- ggplot(trump, aes(x=date, y=net)) +
geom_line(size=1) + theme_bw() +
theme(axis.text.x=element_text(angle=0, hjust=1, size=10),
axis.text.y=element_blank(),
axis.title.y=element_blank()) +
ylab("Net Approval") +
xlab("") + scale_x_date(date_labels = "%Y %b %d",
limit=c(as.Date("2017-12-25"),as.Date("2018-06-01"))) + theme(axis.text.x=element_text(angle=30, hjust=1)) +
geom_vline(xintercept= as.numeric(as.Date("2018-01-13")), linetype=3, size=1, color="red") + ## Stormy D. alleg.
geom_vline(xintercept= as.numeric(as.Date("2018-01-25")), linetype=3, size=1, color="red") + ## Trump denies
geom_vline(xintercept= as.numeric(as.Date("2018-02-12")), linetype=3, size=1, color="red")  + ## Cohen admits
geom_vline(xintercept= as.numeric(as.Date("2018-03-06")), linetype=3, size=1, color="red")  +## Stormy lawsuit, Trump denies
geom_vline(xintercept= as.numeric(as.Date("2018-03-25")), linetype=3, size=1, color="red") + ## 60 mins interview, Trump still denies
geom_vline(xintercept= as.numeric(as.Date("2018-04-01")), linetype=3, size=1, color="red")  + ## Trump denies
geom_vline(xintercept= as.numeric(as.Date("2018-04-09")), linetype=3, size=1, color="red")  +## Cohen faces crim. investigation
geom_vline(xintercept= as.numeric(as.Date("2018-04-20")), linetype=3, size=1, color="red") + ## Trump denies
geom_vline(xintercept= as.numeric(as.Date("2018-05-05")), linetype=3, size=1, color="red") + ## Trump admits
geom_text(aes(x = as.Date("2018-01-09"), y = 30, label = "Stormy D. alleg."), angle=90, size=4) +
geom_text(aes(x = as.Date("2018-01-21"), y = 30, label = "Trump denies"), angle=90, size=4) +
geom_text(aes(x = as.Date("2018-02-08"), y = 30, label = "Cohen admits"), angle=90, size=4) +
geom_text(aes(x = as.Date("2018-02-27"), y = 30, label = "Stormy D. lawsuit, \n Trump denies"), angle=90, size=4) +
geom_text(aes(x = as.Date("2018-03-18"), y = 30, label = "Interview with Stormy D., \n Trump denies"), angle=90, size=4) +
geom_text(aes(x = as.Date("2018-03-29"), y = 30, label = "Trump denies"), angle=90, size=4) +
geom_text(aes(x = as.Date("2018-04-06"), y = 30, label = "Cohen arrested"), angle=90, size=4) +
geom_text(aes(x = as.Date("2018-04-17"), y = 30, label = "Trump denies"), angle=90, size=4) +
geom_text(aes(x = as.Date("2018-05-02"), y = 30, label = "Trump admits"), angle=90, size=4) +
ggtitle("Trump: Stormy Daniels Scandal Timeline") + ylim(-30,50)
trump_plot
Sys.setlocale("LC_TIME", "English")
clinton_plot <- ggplot(clinton, aes(x=date, y=net)) +
geom_line(size=1) + theme_bw() +
xlab("") + scale_x_date(date_labels = "%Y %b %d",
limit=c(as.Date("1998-01-01"),as.Date("1999-02-01"))) +
theme(axis.text.x=element_text(angle=30, hjust=1, size=10),
axis.text.y=element_text(angle=0, hjust=1, size=12),
axis.title.y=element_text(angle=90, hjust=0.5, size=13)) +
ylab("Net Approval") + geom_vline(xintercept = as.numeric(as.Date("1998-01-19")),
linetype=3, size=1, color="red") +
geom_vline(xintercept = as.numeric(as.Date("1998-02-01")),
linetype=3, size=1, color="red") +
geom_vline(xintercept = as.numeric(as.Date("1998-08-14")),
linetype=3, size=1, color="red") +
geom_vline(xintercept = as.numeric(as.Date("1998-12-20")),
linetype=3, size=1, color="red") +
geom_text(aes(x = as.Date("1998-01-10"), y = -15, label = "Lewinsky Alleg."), angle=90, size=4) +
geom_text(aes(x = as.Date("1998-02-08"), y = -15, label = "Clinton Denies"), angle=90, size=4) +
geom_text(aes(x = as.Date("1998-08-05"), y = -15, label = "Clinton Admits"), angle=90, size=4) +
geom_text(aes(x = as.Date("1998-05-01"), y = 5, label = "Legal Investigations"), angle=0, size=4) +
geom_text(aes(x = as.Date("1998-12-11"), y = -10, label = "House Impeachment"), angle=90, size=4) +
geom_segment(aes(x=as.Date("1998-02-10"), y=0, xend=as.Date("1998-08-10"), yend=0), linetype=3, size=1, color="red") +
ggtitle("Clinton: Lewinsky Scandal Timeline") + ylim (-30,50)
clinton_plot
plot_grid(clinton_plot, trump_plot)
